package com.zjdiepu.www.util;

import com.zjdiepu.www.model.third.request.juhe.JuheExactEstimationRequest;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;
import com.zjdiepu.www.model.yw.dto.YwBusinessLoan;
/**
 * 项目名称 dpqc-parent-manager-information <br/> 
 * 类名称 CarHelper <br/>  
 * 类描述 车辆信息处理 <br/>    
 * 创建人 xiongxiaotun <br/> 
 * 创建时间 2017年4月29日 下午7:58:52  <br/>   
 * 修改人 xiongxiaotun <br/> 
 * 修改时间 2017年4月29日 下午7:58:52   <br/>  
 * 修改备注   <br/> 
 * @version V1.0   <br/>
 */
public class CarHelper {
	/**
	 * @author xiongxiaotun <br/>
	 * @Title hasEstimate  <br/>
	 * @Description 判断是否已经估价格  <br/>
	 * @param obj
	 * @return
	 * @version V1.0  <br/>
	 */
	public static boolean hasEstimate(YwBusinessCar newCar, YwBusinessCar oldCar) {
		if (newCar == oldCar)
			return true;
		if (oldCar == null)
			return true;
		if (newCar.getCarStatus() == null) {
			if (oldCar.getCarStatus() != null)
				return false;
		} else if (!newCar.getCarStatus() .equals(oldCar.getCarStatus()))
			return false;
		
		if (newCar.getCarPurpose() == null) {
			if (oldCar.getCarPurpose() != null)
				return false;
		} else if (!newCar.getCarPurpose().equals(oldCar.getCarPurpose()))
			return false;
		
		if (newCar.getEvaluateCity() == null) {
			if (oldCar.getEvaluateCity() != null)
				return false;
		} else if (!newCar.getEvaluateCity().equals(oldCar.getEvaluateCity()))
			return false;
		
		if (newCar.getEvaluateProvince() == null) {
			if (oldCar.getEvaluateProvince() != null)
				return false;
		} else if (!newCar.getEvaluateProvince().equals(oldCar.getEvaluateProvince()))
			return false;
		
		if (newCar.getCarBrand() == null) {
			if (oldCar.getCarBrand() != null)
				return false;
		} else if (!newCar.getCarBrand().equals(oldCar.getCarBrand()))
			return false;
		
		if (newCar.getCarSeries() == null) {
			if (oldCar.getCarSeries() != null)
				return false;
		} else if (!newCar.getCarSeries().equals(oldCar.getCarSeries()))
			return false;
		
		if (newCar.getCarModel() == null) {
			if (oldCar.getCarModel() != null)
				return false;
		} else if (!newCar.getCarModel().equals(oldCar.getCarModel()))
			return false;
		
		if (newCar.getStartYear() == null) {
			if (oldCar.getStartYear() != null)
				return false;
		} else if (!newCar.getStartYear().equals(oldCar.getStartYear()))
			return false;
		
		if (newCar.getStartMonth() == null) {
			if (oldCar.getStartMonth() != null)
				return false;
		} else if (!newCar.getStartMonth().equals(oldCar.getStartMonth()))
			return false;
	
		if (newCar.getMileage() == null) {
			if (oldCar.getMileage() != null)
				return false;
		} else if (!newCar.getMileage().equals(oldCar.getMileage()))
			return false;
		
		if (newCar.getPrice() == null) {
			if (oldCar.getPrice() != null)
				return false;
		} else if (!newCar.getPrice().equals(oldCar.getPrice()))
			return false;
		return true;
	}
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title hasEstimate  <br/>
	 * @Description 判断是否已经估价格 <br/>
	 * @param request
	 * @param oldCar
	 * @return
	 * @version V1.0  <br/>
	 */
	public static boolean hasEstimate(JuheExactEstimationRequest request, YwBusinessCar oldCar) {
		if(request == null){
			return true;
		}
		if (oldCar == null)
			return false;
		
		if (request.getCarStatus() == null) {
			if (oldCar.getCarStatus() != null)
				return false;
		} else if (!request.getCarStatus().equals(Integer.valueOf(oldCar.getCarStatus().trim())))
			return false;
		
		if (request.getPurpose() == null) {
			if (oldCar.getCarPurpose() != null)
				return false;
		} else if (!request.getPurpose().equals(Integer.valueOf(oldCar.getCarPurpose().trim())))
			return false;
		
		if (request.getCity() == null) {
			if (oldCar.getEvaluateCity() != null)
				return false;
		} else if (!request.getCity().equals(Integer.valueOf(oldCar.getEvaluateCity().trim())))
			return false;
		
		if (request.getProvince() == null) {
			if (oldCar.getEvaluateProvince() != null)
				return false;
		} else if (!request.getProvince().equals(Integer.valueOf(oldCar.getEvaluateProvince().trim())))
			return false;
		
		if (request.getCar() == null) {
			if (oldCar.getCarModel() != null)
				return false;
		} else if (!request.getCar().equals(Integer.valueOf(oldCar.getCarModel().trim())))
			return false;
		
		if (request.getUsedDate() == null) {
			if (oldCar.getStartYear() != null)
				return false;
		} else if (!request.getUsedDate().equals(oldCar.getStartYear()))
			return false;
		
		if (request.getUsedDateMonth() == null) {
			if (oldCar.getStartMonth() != null)
				return false;
		} else if (!Integer.valueOf(request.getUsedDateMonth().trim()).equals(oldCar.getStartMonth()))
			return false;
	
		if (request.getMileage() == null) {
			if (oldCar.getMileage() != null)
				return false;
		} else if (!request.getMileage().equals(oldCar.getMileage()))
			return false;
		
		if (request.getPrice() == null) {
			if (oldCar.getPrice() != null)
				return false;
		} else if (!oldCar.getPrice().equals(request.getPrice()))
			return false;
		return true;
	}
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title hasCalculation  <br/>
	 * @Description 判断是否已经计算贷款  <br/>
	 * @param newYwBusinessLoan
	 * @param oldYwBusinessLoan
	 * @param currentBankRate 当前银行利率
	 * @param oldCarType 车辆类型
	 * @return
	 * @version V1.0  <br/>
	 */
	public static boolean hasCalculation(YwBusinessLoan newYwBusinessLoan, YwBusinessLoan oldYwBusinessLoan, Double currentBankRate, String oldCarType) {
		return false;
//		if(newYwBusinessLoan == null){
//			return true;
//		}
//		if (oldYwBusinessLoan == null)
//			return false;
//		
//		if (newYwBusinessLoan.getCarType() == null) {
//			if (oldCarType != null)
//				return false;
//		} else if (!newYwBusinessLoan.getCarType().equals(oldCarType.trim()))
//			return false;
//		
//		if (newYwBusinessLoan.getLoanBank() == null) {
//			if (oldYwBusinessLoan.getLoanBank() != null)
//				return false;
//		} else if (!newYwBusinessLoan.getLoanBank().equals(oldYwBusinessLoan.getLoanBank().trim()))
//			return false;
//		
//		if (newYwBusinessLoan.getLoanType() == null) {
//			if (oldYwBusinessLoan.getLoanType() != null)
//				return false;
//		} else if (!newYwBusinessLoan.getLoanType().equals(oldYwBusinessLoan.getLoanType()))
//			return false;
//		
//		if("02".equals(newYwBusinessLoan.getLoanType())){ //高息模式
//			if (newYwBusinessLoan.getCcol1() == null) { //取整数模式
//				if (oldYwBusinessLoan.getCcol1() != null)
//					return false;
//			} else if (!newYwBusinessLoan.getCcol1().equals(oldYwBusinessLoan.getCcol1()))
//				return false;
//		}
//		
//		if (newYwBusinessLoan.getCarPrice() == null) {
//			if (oldYwBusinessLoan.getCarPrice() != null)
//				return false;
//		} else if (!newYwBusinessLoan.getCarPrice().equals(oldYwBusinessLoan.getCarPrice()))
//			return false;
//		
//		if (newYwBusinessLoan.getCarAge() == null) {
//			if (oldYwBusinessLoan.getCarAge() != null)
//				return false;
//		} else if (!newYwBusinessLoan.getCarAge().equals(oldYwBusinessLoan.getCarAge()))
//			return false;
//		
//		if (newYwBusinessLoan.getLoanMonth() == null) {
//			if (oldYwBusinessLoan.getLoanMonth() != null)
//				return false;
//		} else if (!newYwBusinessLoan.getLoanMonth().equals(oldYwBusinessLoan.getLoanMonth()))
//			return false;
//		
//		if (currentBankRate == null) {
//			if (oldYwBusinessLoan.getBankRate() != null)
//				return false;
//		} else if (!currentBankRate.equals(oldYwBusinessLoan.getBankRate()))
//			return false;
//		
//	
//		if (newYwBusinessLoan.getLoanAmount() == null) {
//			if (oldYwBusinessLoan.getLoanAmount() != null)
//				return false;
//		} else if (!newYwBusinessLoan.getLoanAmount().equals(oldYwBusinessLoan.getLoanAmount()))
//			return false;
//		
//		if (newYwBusinessLoan.getServicePrice() == null) {
//			if (oldYwBusinessLoan.getServicePrice() != null)
//				return false;
//		} else if ((newYwBusinessLoan.getServicePrice() == null ? 0 :newYwBusinessLoan.getServicePrice().doubleValue())
//				!= (oldYwBusinessLoan.getServicePrice() == null ? 0 :oldYwBusinessLoan.getServicePrice().doubleValue()))
//			return false;
//		
//		if (StringUtils.isBlank(newYwBusinessLoan.getCcol2())) {
//			if (StringUtils.isBlank(oldYwBusinessLoan.getCcol2()))
//				return false;
//		} else if (new BigDecimal(newYwBusinessLoan.getCcol2()).setScale(6, RoundingMode.HALF_UP).doubleValue() != (StringUtils.isBlank(oldYwBusinessLoan.getCcol2()) ? 0 : new BigDecimal(oldYwBusinessLoan.getCcol2()).setScale(6, RoundingMode.HALF_UP).doubleValue()))
//			return false;
//		
//		return true;
	}
}
